﻿@{
    ViewData["Title"] = "当前任务列表";
    ViewData["Mbx"] = "监控管理";
    Layout = "_Default";
}

<link rel="stylesheet" type="text/css" href="~/css/buttons.css" />
@*<meta http-equiv="refresh" content="5">*@
@section css{
    <style>
        
        .fliter {
            /*width: 80%;*/
            height: 40px;
            align-items: center;
            display: flex;
            margin-bottom: 10px;
        }
        .add{
            width: 80%;
            height: 60px;
            align-items: center;
            display: flex;
        }
        .fliter .search-btn {
            margin-left: 20px;
        }
        .fliter .input-text{
            width: 200px;
        }
        .fliter .label-eq-name{
            margin-left: 20px;
        }
        .fliter .label-eq-code {
            margin-left: 20px;
        }
        .btn-add {
            margin-left: 20px;
        }
        .select-box{
            width: 200px
        }
        .button-rounded{
            padding: 5px 10px;
        }
    </style>
}
@section gray{
@*<div class="add">
<span class="l">
    <a class="btn btn-primary radius btn-add" href="javascript:;" onclick="common_add('添加路径详情配置','/routedetailinfo/routedetailinfoaddoredit','600')">
        <i class="Hui-iconfont">&#xe600;</i> 新增
    </a>
</span>
</div>*@
@*<div class="fliter">
    <label class="label-eq-name">起  始  工  位：</label>
    <input type="text" class="input-text" value="" placeholder="请输入起始工位" id="FromStation" name="FromStation">
    <label class="label-eq-name">目  标  工  位：</label>
    <input type="text" class="input-text" value="" placeholder="请输入目标工位" id="ToStation" name="ToStation">
    <label class="label-eq-name">WMS起始工位：</label>
    <input type="text" class="input-text" value="" placeholder="请输入WMS起始工位" id="WmsFromStation" name="WmsFromStation">
    <label class="label-eq-code">WMS目标工位：</label>
    <input type="text" class="input-text" value="" placeholder="请输入WMS目标工位" id="WmsToStation" name="WmsToStation">
</div>*@
<div class="fliter">
    @*<label class="label-eq-name">WMS起始位置：</label>
    <input type="text" class="input-text" value="" placeholder="请输入WMS起始位置" id="WmsFromPosition" name="WmsFromPosition">
    <label class="label-eq-code">WMS目标位置：</label>
    <input type="text" class="input-text" value="" placeholder="请输入WMS目标位置" id="WmsToPosition" name="WmsToPosition">*@
    <label class="label-eq-code">托  盘  编  码：</label>
    <input type="text" class="input-text" value="" placeholder="请输入托盘编码" id="PalletCode" name="PalletCode">
    <label class="label-eq-name">任  务  编  码：</label>
    <input type="text" class="input-text" value="" placeholder="请输入任务编码" id="TaskCode" name="TaskCode">
    
    <label class="label-eq-name">任  务  状  态：</label>
    <span class="select-box">
        <select class="select" size="1" name="TaskState" id="TaskState">
            @*<option value="-1" selected>--请选择--</option>*@
            @foreach (var item in @Model.TaskStates)
            {
                if(item.TaskStateValue==3||item.TaskStateValue==4 ||item.TaskStateValue==5){
                    continue;
                }
                <option value="@item.TaskStateValue">@item.TaskStateName</option>
            }
        </select>
    </span>
    
    <label class="label-eq-name">巷道：</label>
        <span class="select-box">
            <select class="select" size="1" name="RouteInfo" id="RouteInfo">

                @foreach (var item in @Model.ScItems)
                {
                    <option value="@item.ScValue">@item.ScName</option>
                }
            </select>
        </span>
    <input class="btn btn-primary radius search-btn" type="button" onclick="search()" value="&nbsp;&nbsp;搜索&nbsp;&nbsp;">
</div>



}
<table class="table table-border table-bordered table-hover table-bg table-sort" style="background-color: #FFFFFF;">
    <thead>
    </thead>
    <tbody>
    </tbody>
</table>

@section javascript{
<script>
    $(function(){
        initData("",0,-1);
    });

    var t2 = window.setInterval(function() {

        search();

    },120000);

    function search(){
        var PalletCode = $("#PalletCode").val();
        var TaskCode = $("#TaskCode").val();
        var TaskState = $("#TaskState").val();
        var RouteInfo = $("#RouteInfo").val();
        initData(PalletCode, TaskCode, TaskState,RouteInfo);
    }

    function initData( PalletCode, TaskCode, TaskState,RouteInfo){
        $('.table-sort').dataTable({
            bProcessing: true, //DataTables 载入数据时，是否显示‘进度’提示
            bAutoWidth: true, //自动宽度
            bSort: false, //排序功能
            sScrollX: true, //横向滑动
            paging : true, //是否分页
            bInfo: true, //页脚信息,默认为 true
            bStateSave: false, //状态保存
            sPaginationType: "full_numbers", //分页显示样式
            serverSide: true, //启用服务器分页
            //sAjaxSource: "/admin/functionlist", //服务端请求数据接口
            searching: false, //关闭 datatables 的搜索框
            destroy: true, //解决重新渲染问题
            iDisplayLength: 10, //每页显示数量
            ajax:{
                    url: "/currentworktaskinfo/getcurrentallworktaskinfo",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded",
                    async: false,
                    dataType: "json",
                    data: function(data){
                        //data.FromStation = FromStation;
                        //data.ToStation = ToStation;
                        //data.WmsFromStation = WmsFromStation;
                        //data.WmsToStation = WmsToStation;
                        //data.WmsFromPosition = WmsFromPosition;
                        //data.WmsToPosition = WmsToPosition;
                        data.PalletCode = PalletCode;
                        data.TaskCode = TaskCode;
                        //data.WmsTaskCode = WmsTaskCode;
                        data.RouteInfo = RouteInfo;
                        data.TaskState = TaskState;
                        //data.TaskProcessState = TaskProcessState;
                    },
                    dataFilter: function(json){
                        console.log(json);
                        return json;
                    }
               },

            aoColumns:[
                // mDataProp：绑定数据属性
                // sDefaultContent：设置默认值
                // sClass：添加 class 属性，不懂的直接去掉
                // sTtile：设置列标题
                // sWidth：设置列宽度
                // sTtile 设置的内容，会替换到 html thead 中的“标题”
                //{mDataProp:"js_Id", sClass:"text-c",  sTitle:"编号",sDefaultContent:""},
                {mDataProp:"js_Id", sClass:"text-c", sTitle:"ID",sDefaultContent:"",sWidth:"150px"},
                {mDataProp:"routeInfo", sClass:"text-c", sTitle:"路径",sDefaultContent:"",sWidth:"100px"},
                {mDataProp:"priority", sClass:"text-c", sTitle:"优先级",sDefaultContent:"",sWidth:"30px"},
                {mDataProp:"palletCode",  sClass:"text-c", sTitle:"托盘编码",sDefaultContent:"",sWidth:"120px"},
                {mDataProp:"taskCode",  sClass:"text-c", sTitle:"任务编码",sDefaultContent:"",sWidth:"80px"},
                {mDataProp:"taskTypeFormat",  sClass:"text-c", sTitle:"任务类型",sDefaultContent:"",sWidth:"50px"},
                {mDataProp:"taskProcessStateFormat",  sClass:"text-c", sTitle:"处理状态",sDefaultContent:"",sWidth:"120px"},
                {mDataProp:"taskStateFormat",  sClass:"text-c", sTitle:"任务状态",sDefaultContent:"",sWidth:"50px"},
                {mDataProp:"saveTimeFormat",  sClass:"text-c", sTitle:"保存时间",sDefaultContent:"",sWidth:"150px"},
                {mDataProp:"updateTimeFormat",  sClass:"text-c", sTitle:"更新时间",sDefaultContent:"",sWidth:"150px"},
                {mDataProp:"wmsTaskCode",  sClass:"text-c", sTitle:"WMS依赖任务编码",sDefaultContent:"",sWidth:"120px"},
                {mDataProp:"wmsFromStation",  sClass:"text-c", sTitle:"WMS起始工位",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"wmsFromPosition",  sClass:"text-c", sTitle:"WMS起始位置",sDefaultContent:"",sWidth:"100px"},
                {mDataProp:"wmsToStation",  sClass:"text-c", sTitle:"WMS目标工位",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"wmsToPosition",  sClass:"text-c", sTitle:"WMS目标位置",sDefaultContent:"",sWidth:"100px"},
                {mDataProp:"uploadWmsStateFormant",  sClass:"text-c", sTitle:"WMS上传状态",sDefaultContent:"",sWidth:"80px"},
                {mDataProp:"uploadWmsTimeFormat",  sClass:"text-c", sTitle:"上传WMS时间",sDefaultContent:"",sWidth:"150px"},
                {mDataProp:"currentDetailTaskStateFormat",  sClass:"text-c", sTitle:"当前节点状态",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"dispatchTypeDescription",  sClass:"text-c", sTitle:"当前节点调度类型",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"currentFromEquipment",  sClass:"text-c", sTitle:"当前节点起始设备",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"currentFromCargo",  sClass:"text-c", sTitle:"当前节点起始货位",sDefaultContent:"",sWidth:"100px"},
                {mDataProp:"currentToEquipment",  sClass:"text-c", sTitle:"当前节点目标设备",sDefaultContent:"",sWidth:"70px"},
                {mDataProp:"currentToCargo",  sClass:"text-c", sTitle:"当前节点目标货位",sDefaultContent:"",sWidth:"100px"},
                {mDataProp:"currentCreateTimeFormat",  sClass:"text-c", sTitle:"当前节点创建时间",sDefaultContent:"",sWidth:"150px"},
                {mDataProp:"currentUpdateTimeFormat",  sClass:"text-c", sTitle:"当前节点更新时间",sDefaultContent:"",sWidth:"150px"},
                
                {mDataProp:"js_Id", sClass:"text-c", sTitle:"操作",sWidth:"80px",
                 mRender: function(data, type, row){
                       var html= "<a title=\"编辑\" href=\"javascript:;\" onclick=\"common_add('查看任务详情',\'/worktaskinfo/taskroutedetailinfo/"+data+"','1600')\" class=\"button-glow button-rounded button-raised button-primary\" style=\"text-decoration:none\">查看任务</a>";
                          return html;
                    }
                 }
                
            ],

            fixedColumns: {
                leftColumns: 2,  //开启左侧两列固定
                rightColumns: 1 //开启右侧1列固定
            },
            //rowCallback: RowCallBack,
            oLanguage: { //国际化配置
                sProcessing : "正在获取数据，请稍后...",
                sLengthMenu : "显示 _MENU_ 条",
                sZeroRecords : "没有您要搜索的内容",
                sInfo : "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                sInfoEmpty : "记录数为0",
                sInfoFiltered : "(全部记录数 _MAX_ 条)",
                sInfoPostFix : "",
                sSearch : "从当前数据中检索： ",
                sUrl : "",
                oPaginate: {
                    sFirst : "首页",
                    sPrevious : "上一页",
                    sNext : "下一页",
                    sLast : "尾页"
                }
            }
        });


    }

    function DelRouteDetailInfoAsync(id) {
        console.log(id);
        popupConfirm("确定删除该路径配置吗？",0, function(){
            var data = { 'id' : id };
            SubmitFormForAjax("/routedetailinfo/deleteroutedetailinfo", data, function (data) {
                if (data.result) {
                    popupAlert('删除成功！',1,function(){
                        location.reload();//刷新页面
                    });
                }else{
                popupAlert('删除失败！',1,function(data){
                    layer.close(data);
                });
                }
            },true);

        });
    }
    
</script>
}
